package main

import (
	"database/sql"
	"fmt"
	"github.com/yourusername/gox/pkg/runtime"
)

type User struct {
	ID    int
	Name  string
	Email string
}

func GetUser(db *sql.DB, userID int, status string) (*User, error) {
	query := func() *runtime.Query {
		__gox_sql_0_builder := runtime.NewQueryBuilder()
		__gox_sql_0_builder.AddText("SELECT id, name, email FROM users WHERE id =")
		__gox_sql_0_builder.AddText(fmt.Sprintf("%v", userID))
		__gox_sql_0_builder.AddText("AND status =")
		__gox_sql_0_builder.AddText(fmt.Sprintf("%v", status))
		__gox_sql_0_builder.AddText("or status =")
		__gox_sql_0_builder.AddParam(status)
		if __result := func() (__result interface{}) {
			if userID > 0 {
				return func() *runtime.Query {
					__nested_sql_0_builder := runtime.NewQueryBuilder()
					__nested_sql_0_builder.AddText("ok no problem")
					if __result := func() (__result interface{}) {
						if status != "ok" {
							return "fuck"
						}
						return __result
					}(); __result != nil {
						__nested_sql_0_builder.AddText(fmt.Sprintf("%v", __result))
					}
					__nested_sql_0 := __nested_sql_0_builder.Build()
					return __nested_sql_0
				}()
			}
			return __result
		}(); __result != nil {
			__gox_sql_0_builder.AddText(fmt.Sprintf("%v", __result))
		}
		__gox_sql_0 := __gox_sql_0_builder.Build()
		return __gox_sql_0
	}()

	row := db.QueryRow(query.String(), query.Args()...)

	var user User
	err := row.Scan(&user.ID, &user.Name, &user.Email)
	if err != nil {
		return nil, err
	}

	return &user, nil
}

func main() {
	fmt.Println("GoX 示例程序")
}
